home *** CD-ROM | disk | FTP | other *** search
/ What PC? 1998 December / WPCDEC98.ISO / dxrs / Mainmn12.dxr / internet_26_Acrobat-specific cut-n-paste Lingo handlers.ls < prev    next >
Encoding:
Text File  |  1998-10-12  |  3.5 KB  |  128 lines

  1. on acrobatWindowIDs
  2.   set taskIDs to getNamedTasks("Acrobat")
  3.   set theCount to count(taskIDs)
  4.   if theCount < 1 then
  5.     warning("acrobatWindowIDs(): no Acrobat tasks")
  6.     return []
  7.   end if
  8.   set windowIDs to []
  9.   repeat with i = 1 to theCount
  10.     set thisTaskID to getAt(taskIDs, i)
  11.     set thisWindowIDs to getTaskWindowIDs(thisTaskID)
  12.     if word 1 of thisWindowIDs <> "Error:" then
  13.       set nw to the number of words in thisWindowIDs
  14.       if nw >= 1 then
  15.         repeat with j = 1 to nw
  16.           set thisWindowText to word j of thisWindowIDs
  17.           set thisWindowID to integer(thisWindowText)
  18.           if integerp(thisWindowID) then
  19.             if not windowExists(thisWindowID) then
  20.               next repeat
  21.             end if
  22.             if not windowHasChildren(thisWindowID) then
  23.               next repeat
  24.             end if
  25.             if windowParent(thisWindowID) <> 0 then
  26.               next repeat
  27.             end if
  28.             if not (windowName(thisWindowID) contains "Acrobat Reader") then
  29.               next repeat
  30.             end if
  31.             if not (windowType(thisWindowID) contains "Afx:") then
  32.               next repeat
  33.             end if
  34.             add(windowIDs, thisWindowID)
  35.           end if
  36.         end repeat
  37.       end if
  38.     end if
  39.   end repeat
  40.   if count(windowIDs) < 1 then
  41.     warning("acrobatWindowIDs(): no Acrobat windows")
  42.     return []
  43.   end if
  44.   return windowIDs
  45. end
  46.  
  47. on acrobatWindowID
  48.   set windowIDs to acrobatWindowIDs()
  49.   if count(windowIDs) > 1 then
  50.     warning("acrobatWindowID(): ambiguous: more than one Acrobat window")
  51.     return 0
  52.   end if
  53.   if count(windowIDs) < 1 then
  54.     warning("acrobatWindowID(): no Acrobat window")
  55.     return 0
  56.   end if
  57.   return getAt(windowIDs, 1)
  58. end
  59.  
  60. on killAllAcrobatTasks
  61.   global gShowWarning
  62.   set oldWarning to gShowWarning
  63.   hideWarnings()
  64.   set windowIDs to acrobatWindowIDs()
  65.   if oldWarning then
  66.     showWarnings()
  67.   end if
  68.   set theCount to count(windowIDs)
  69.   if theCount < 1 then
  70.     return 1
  71.   end if
  72.   set success to 1
  73.   set killed to 1
  74.   set tasksToCheck to []
  75.   repeat with i = 1 to theCount
  76.     set thisWindowID to getAt(windowIDs, i)
  77.     set theTask to getWindowTask(thisWindowID)
  78.     add(tasksToCheck, theTask)
  79.     if not windowExists(thisWindowID) then
  80.       next repeat
  81.     end if
  82.     cancelAnyDialogs(thisWindowID)
  83.     closeWindow(thisWindowID)
  84.     set giveUpTicks to the ticks + (10 * 60)
  85.     set killed to 0
  86.     repeat while the ticks < giveUpTicks
  87.       if not windowExists(thisWindowID) then
  88.         set killed to 1
  89.         exit repeat
  90.       end if
  91.       feedTimeSlice(theTask)
  92.       feedGenericTimeSlice()
  93.     end repeat
  94.     if not killed then
  95.       warning("killAllAcrobatTasks(): ten second timeout while killing window " & i & " of  " & theCount)
  96.       set success to 0
  97.     end if
  98.   end repeat
  99.   if success <> 1 then
  100.     warning("killAllAcrobatTasks(): not all windows killed")
  101.     return 0
  102.   end if
  103.   set giveUpTicks to the ticks + 30
  104.   repeat while the ticks < giveUpTicks
  105.     feedGenericTimeSlice()
  106.   end repeat
  107.   set theCount to count(tasksToCheck)
  108.   if theCount < 1 then
  109.     return 1
  110.   end if
  111.   set giveUpTicks to the ticks + (10 * 60)
  112.   repeat while the ticks < giveUpTicks
  113.     set thisTask to getAt(tasksToCheck, 1)
  114.     if taskIsRunning(thisTask) then
  115.       rudeQuitTask(thisTask, 0)
  116.     else
  117.       deleteAt(tasksToCheck, 1)
  118.     end if
  119.     feedGenericTimeSlice()
  120.     if count(tasksToCheck) = 0 then
  121.       windowToFront(directorMainWindow())
  122.       return 1
  123.     end if
  124.   end repeat
  125.   warning("killAllAcrobatTasks(): ten-second timeout, not all tasks killed")
  126.   return 0
  127. end
  128.